ecExtract Files collection

The ecExtract control has a Files collection that is loaded with file objects once a valid cabinet Filename is specified. You can use this collection to choose which files should be extracted by the Extract method.

Item (default), ItemByName

object.Files.Item(Index As Integer)
object.Files(Index As Integer)
object.Files.ItemByName(Filename As String)

The Item and ItemByName return an ecExtractFile object, based on either the file's index (starting at 1) or its filename. You can also use a For..Next loop to iterate through the file objects in this collection.

Count, ExtractCount

object.Files.Count
object.Files.ExtractCount

The Count property returns the number of files that are in the cabinet, whereas the ExtractCount method returns only the number of files that are selected for extraction.

SelectAll, SelectNone

object.Files.SelectAll
object.Files.SelectNone

The SelectAll and SelectNone select all or none of the files in the collection for extraction.

Item.Filename (default)

fileobject.Filename

Each file in the Files collection has a Filename property. This property contains the name of the individial file, as well as path information if it was included. Examples: "MyFile.doc" "ThisFile2.html" "Relative Path\SubFolder 2\Filename.ext"

Item.Selected

fileobject.Selected = Boolean

Each file in the Files collection has a flag, where True indicates that the file will be extracted when the Extract method is called. This value begins at False, indicating that the file will not be extracted. You can set this value individually, or you can set all of the values using the SelectAll or SelectNone methods.

Item.AutoRun

fileobject.AutoRun

Each file in the Files collection has a flag indicating whether or not the file should be opened upon extraction. Most programs do not support this flag.

Item.UncompressedSize

fileobject.UncompressedSize

Each file in the Files collection has an UncompressedSize property, a value indicating the full size of the file before it was compressed. The cabinet format does not support the determination of the final compressed size of the file, or the compression ratio, so there is no CompressedSize property.

Example

The following code demonstrates some of the potential uses for the Files collection. This example goes through a cabinet, and extracts only the HTML files to a specific folder.

' Beginning of sample

Private Sub Command1_Click()
 Dim MyFile As ecExtractFile
    ecExtract1.Filename = "C:\Windows\Desktop\MyCab.cab"
    ecExtract1.Files.SelectNone
    For Each MyFile In ecExtract1.Files
        With MyFile
            If LCase$(Right$(.Filename, 4)) = "html" Then .Selected = True
        End With
    Next MyFile
    ecExtract1.Extract "C:\Windows\Desktop\New Folder"
End Sub

Private Sub ecExtract1_Progress(ByVal Filename As String, ByVal PercentDone As Integer)
    Label1.Caption = Filename & "% complete..."
End Sub

' End of sample

See Also

Extract method